﻿
Imports storoomc

Public Class stornode
    Inherits storoomTalk
    Implements comparableStorageInterface(Of stornode), stornodebase

    Public host As String = Nothing
    Public port As Int32 = 0
    Public retrytimes As UInt64 = talkTime.room2node.retrytimes

    Private Function getstoroom(ByRef host As String, ByRef port As Int32, ByRef retrytimes As Int64) As Boolean
        copy(host, Me.host)
        port = Me.port
        retrytimes = Me.retrytimes
        Return True
    End Function

    Public Sub New(ByVal inputhost As String, ByVal inputport As Int32)
        copy(host, inputhost)
        port = inputport
        holdTime = talkTime.room2node.holdtime
        liveTime = talkTime.room2node.livetime
    End Sub

    Public Sub New(ByVal inputhost As String, ByVal inputport As String)
        Me.New(inputhost, convertor.toint32(inputport))

        'extra config confirm
        Dim port As Int32
        If Not convertor.toint32(inputport, port) Then
            raiseError("cannot convert inputport " + inputport + " to int32.", errorHandle.errorType.warning)
        End If
    End Sub

    Public Shadows Sub initial()
        MyBase.initial(AddressOf getstoroom)
    End Sub

    Public Overloads Function CompareTo(ByVal other As stornode) As Int32 Implements IComparable(Of stornode).CompareTo
        Return compare(Of stornode, stornode, storoomTalk)(Me, other)
    End Function

    Public Overloads Function CompareTo(ByVal other As stornodebase) As Int32 _
                                        Implements IComparable(Of stornodebase).CompareTo
        Return cast_compare(Of stornode, stornodebase, stornode)(Me, other)
    End Function

    Public Function display(Optional ByVal length As Int64 = 64) As String Implements IDisplay.display
        Return displayHostPort(host, port)
    End Function
End Class
